package de.hauschild.gmltracer.gml.impl.value.point;

import org.apache.commons.math.geometry.Vector3D;

import de.hauschild.gmltracer.gml.Environment;
import de.hauschild.gmltracer.gml.TokenStack;
import de.hauschild.gmltracer.gml.impl.AbstractToken;
import de.hauschild.gmltracer.gml.impl.value.real.RealToken;

public class PointOperatorToken extends AbstractToken {

  @Override
  public void evaluate(final Environment environment, final TokenStack tokenStack) {
    final RealToken z = tokenStack.pop(RealToken.class);
    final RealToken y = tokenStack.pop(RealToken.class);
    final RealToken x = tokenStack.pop(RealToken.class);

    tokenStack.push(new PointToken(new Vector3D(x.getValue(), y.getValue(), z.getValue())));
  }

  @Override
  public String toString() {
    return "point";
  }
}
